package com.shuyun.demo1;

import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.functions.Consumer;
import org.junit.jupiter.api.Test;

/**
 * @description:
 * @author: shuai.chen@shuyun.com
 * @date: 2023/1/13 2:46 PM
 */
public class HelloDemo {

    @Test
    public void test01() {
        // subscribe方法 启动流水线
        Flowable.fromArray("jerry", "tom").subscribe(s -> {
            System.out.println("hello " + s);
        });
    }

    @Test
    public void notLambda(){
        Flowable.fromArray("jerry", "tom").subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Throwable {
                System.out.println("hello " + s);
            }
        });
    }

    /**
     * 方式1：创建流水线，这个流水线 处理的菜（数据）是 字符串
     */
    @Test
    public void create() {
        Observable.fromArray("a", "b", "c").subscribe(s -> {
            System.out.println(s);
        });
    }

    /**
     * 方式2：创建流水线，这个流水线 处理的菜（数据）是 字符串
     */
    @Test
    public void create02() {
        Observable.just("a", "b", "c").subscribe(s -> {
            System.out.println(s);
        });
    }

}
